
function itstock_request(page, post, headers, dest) {
    E(dest).innerHTML = "<div style='text-align:center;'><img src='img/loading.gif'><br><i>Loading...</i></div>";
    var xmlhttp = xml_http_request(post, 'request.php?page='+ page);
    if(xmlhttp.status === 200){
        E(dest).innerHTML = xmlhttp.responseText;
        if(E("header_files") === null) return true;
        var header_files = E("header_files").childNodes;
        if(headers){
            var headID = document.getElementsByTagName("head")[0];
            while(0 < header_files.length){
                if(header_files[0].nodeName === "LINK"){
                    AC(headID, header_files[0]);
                }else if(header_files[0].nodeName === "SCRIPT"){
                    var newScript = CE('script');
                    newScript.type = 'text/javascript';
                    newScript.src = header_files[0].src;
                    AC(headID, newScript);
                    RC(E("header_files"), header_files[0]);
                }
            }
        }
        RC(E(dest), E("header_files"));
        return true;
    } else if(xmlhttp.status === 403) {
      window.location = "index.php";
    }else{
      E(dest).innerHTML = '<p class="error">'+xmlhttp.responseText+'</p>';
    }
    return false;
}

function itstock_request_options(dest, type, name) {
  var args = Array.prototype.slice.call(arguments, 3);
  var fields = '';
  for(var i = 0; i < args.length; i++) {
    var options = E(args[i]).options;
    var value = options[options.selectedIndex].value;
    if(value === '') return;
    fields += '&field[]='+args[i]+'&value[]='+value;
  }
  var xmlhttp = xml_http_request('type='+type+'&name='+name+fields, 'request.php');
  if(xmlhttp.status === 200){
    E(dest).innerHTML = xmlhttp.responseText;
    A(E('e_msg'), 'style', 'display: none;');
  } else {
    E('e_msg').innerHTML = xmlhttp.responseText;
    RA(E('e_msg'), 'style');
  }
}
